﻿Public Class FrmTicket

    Dim position As Integer = 0
    Dim macnx As New PPE3.ClassMySqlConnect("853339_depanneur", "071064")
    Dim nbchamps As Integer = 0
    Dim idInt As Integer
    Public AdEmail As String

    Public Sub CacherColonne(data As DataGridView, colonne As String)

        data.Columns(colonne).Visible = False

    End Sub

    Private Sub FrmTicket_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Me.MdiParent = FrmStart
        Me.Top = 0
        Me.Left = 350

        Dim d As Date = Now
        Dim dD As String = d.Day
        Dim dM As String = d.Month
        Dim dY As String = d.Year

        Dim f As String = dD & "/" & dM & "/" & dY

        lblLe.Text = "VALRAS-PLAGE, le " & f
        lblDateLivraison.Text = f

        macnx.Se_Connecter_MySqlServer()

        dgvClient.DataSource = Nothing
        macnx.viderVue("client")
        dgvClient.DataSource = macnx.Executer_Requete_Select("SELECT * FROM CLIENT WHERE IdClient = '" & lblNumClient.Text & "' ", "client")

        dgvTravail.DataSource = Nothing
        macnx.viderVue("trav")
        dgvTravail.DataSource = macnx.Executer_Requete_Select("SELECT NomTravaux as Descritption , Quantite , Prix as PrixTTC , ( Quantite  *  Prix ) as MontantTTC FROM travauxeffectues WHERE idIntervention = '" & lblNumInter.Text & "' ", "trav")

        tbTTC.Text = macnx.ExecuteScalar("SELECT SUM( (Quantite  *  Prix) ) FROM travauxeffectues WHERE idIntervention = '" & lblNumInter.Text & "' ").ToString()
        Dim HT As Decimal = CInt(tbTTC.Text) * 0.794
        tbHT.Text = HT.ToString
        tbTVA.Text = (CInt(tbTTC.Text) - HT)

        tbAcompte.Text = "0"

        TextBoxRecap.Text = macnx.ExecuteScalar("SELECT EnonceProbleme FROM intervention WHERE IdIntervention = '" & lblNumInter.Text & "' ").ToString()
        tbMateriel.Text = macnx.ExecuteScalar("SELECT MaterielsDeposes FROM intervention WHERE IdIntervention = '" & lblNumInter.Text & "' ").ToString()

        macnx.Se_Deconnecter_MySqlServer()

        lblNom.Text = dgvClient.Rows(0).Cells(1).Value.ToString().ToUpper
        lblPrenom.Text = dgvClient.Rows(0).Cells(2).Value.ToString().Substring(0, 1).ToUpper & lblPrenom.Text.Substring(1, lblPrenom.Text.Length - 1)
        lblAdresse.Text = dgvClient.Rows(0).Cells(3).Value.ToString().ToUpper
        lblCodePostal.Text = dgvClient.Rows(0).Cells(4).Value.ToString()
        lblville.Text = dgvClient.Rows(0).Cells(5).Value.ToString().ToUpper




    End Sub

    Private Sub tbAcompte_TextChanged(sender As System.Object, e As System.EventArgs) Handles tbAcompte.TextChanged
        Try
            If (tbAcompte.Text = "0") Or (tbAcompte.Text = "") Then
                If (tbAcompte.Text = "") Then
                    tbAcompte.Text = "0"
                Else
                    tbNet.Text = tbTTC.Text
                End If
            Else
                tbNet.Text = (CInt(tbTTC.Text) - CInt(tbAcompte.Text)).ToString

            End If
        Catch ex As Exception
            MessageBox.Show("Entrer uniquement des valeurs numériques")
        End Try

    End Sub

    Private Sub btnImprimer_Click(sender As System.Object, e As System.EventArgs) Handles btnImprimer.Click
        btnImprimer.Visible = False
        Me.PrintForm1.Print(Me, PowerPacks.Printing.PrintForm.PrintOption.Scrollable)
        btnImprimer.Visible = True
    End Sub


End Class